package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.DZzxfunds;
import com.hbnu.system.service.DZzxfundsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/DZzxfunds")
@Api(tags = "纵向到账经费相关模块")
public class DZzxfundsController {
    @Autowired
    DZzxfundsService dZfundsService;

    @ApiOperation("纵向到账经费添加")
    @PostMapping("/addDZfunds")
    public Rest<Boolean> AddDZfunds(@RequestBody DZzxfunds dZfunds){
        boolean add = dZfundsService.addDZzxfundsProject(dZfunds);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("纵向到账经费删除")
    @GetMapping("/removeDZfunds")
    public Rest<Boolean> RemoveDZfunds(String id){
        boolean remove= dZfundsService.removeDZzxfundsProject(id);
        return remove ? Rest.success() : Rest.failed();
    }
    @ApiOperation("纵向到账经费更新")
    @PostMapping("/UpdateDZfunds")
    public Rest<Boolean> UpdateDZfunds(@RequestBody DZzxfunds dZfunds){
        boolean update = dZfundsService.updateDZzxfundsProject(dZfunds);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("到账经费-通过纵向项目id查询")
    @GetMapping("/GetDzfundsByPorprojectID")
    public Rest<List<DZzxfunds>> GetDZfundsByTranprojectID(String tranID){
        List<DZzxfunds> paperProjectByPaperID = dZfundsService.getDZzxfundsByPorprojectID(tranID);
        return Rest.success(paperProjectByPaperID);
    }
}
